package main

import (
	"fmt"
	"strings"
)

type book struct{
	title string
	author string
	subject string
	book_id int
}
func main() {
	//var Book1 book
	//Book1.author = "zangsan1"
	//Book1.title = "钢铁是怎样连城的"
	//Book1.subject = "文学"
	//Book1.book_id = 1
	//fmt.Println(Book1)  //{钢铁是怎样连城的 zangsan1 文学 1}

	//var a int
	//a = 1
	//b:=reflect.ValueOf(&a)
	//
	//b.Elem().SetInt(100)
	//fmt.Println(a)
}

//选择排序
func select_sort(arr [7]int) { // 22 2 3 4 5
	for i:=0;i<len(arr); i++ {
		min :=i //定义角标认为最小
		for j:=i+1; j<len(arr); j++ {
			if arr[min]>arr[j] { //进行交换
				min = j
			}
			if(min != i) {
				arr[i], arr[min] = arr[min] , arr[i]
			}
		}
	}
	fmt.Println(arr)
}

//快速排序
func quickOrder(arr[]int) [] int {
	if len(arr)<=1 {
		return  arr
	}
	oneDate := arr[0]
	low :=make([]int,0,0)
	hight:=make([]int,0,0)
	mid:=make([]int,0,0)
	mid = append(mid,oneDate)
	for i:=1;i<len(arr);i++ {
		if arr[i]< oneDate{
			low = append(low,arr[i])
		}else if arr[i]>oneDate {
			hight = append(hight,arr[i])
		}else {
			mid = append(mid,arr[i])
		}
	}
	low , hight = quickOrder(low),quickOrder(hight)
	myarr:=append(append(low,mid...),hight...)
	return  myarr
}
//插入排序
func insert_sort(arr [7]int)  {  //1,11,12,33,22,10,4
	for i:=1;i<len(arr);i++ { //默认第一个已经排好
		tmp := arr[i] //需要判断+1的即可
		for j:=i-1;j>=0;j-- {
			if(tmp>arr[j]){
				arr[j+1] = arr[j]
				arr[j]=tmp
			}else{
				break
			}
		}

	}
	fmt.Println(arr)
}
//冒泡排序
func maopaoOrder(arr [7]int) { // 22 2 3 4 5
	for i:=0;i<len(arr); i++ {
		for j:=1; j<len(arr)-i; j++ {
			fmt.Println(j)
			if arr[j-1] < arr[j] {
				arr[j-1],arr[j]=arr[j],arr[j-1]
			}
		}
	}
	fmt.Println(arr)
}

func aa()  {
	a:="aaa"
	b:=strings.HasSuffix(a,"a")
	fmt.Println(b)
}

